//
//  Host_Detail_Ablum_ViewController.m
//  penzer
//
//  Created by caiyc on 2018/10/1.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "Host_Detail_Ablum_ViewController.h"
#import "collect_Cell.h"
#import "Album_Cell.h"
@interface Host_Detail_Ablum_ViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (weak, nonatomic) IBOutlet UICollectionView *CollectView;
@property(nonatomic,strong)NSMutableArray *dataSouce;

@end

@implementation Host_Detail_Ablum_ViewController
-(NSMutableArray *)dataSouce{
    if(!_dataSouce){
        _dataSouce = [NSMutableArray array];
    }
    return _dataSouce;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpView];
    [self loadData];
    
    // Do any additional setup after loading the view from its nib.
}
-(void)loadData{
    NSDictionary *param = @{@"ac":@"member",@"op":@"member",@"ctrl":@"live",@"anchor_id":self.hostId,@"ta":@"anchor_history_video"};
    [self weqPostHandle:param success:^(id response) {
        if(response){
            NSDictionary *datas = response[@"data"];
            if([response[@"data"][@"video_list"]count]==0){
                [WToast showWithText:@"暂无数据"];
            }else{
                [self.dataSouce addObjectsFromArray:response[@"data"][@"video_list"]];
                [self.CollectView reloadData];
            }
//            self.totalFans.text = [NSString stringWithFormat:@"%@个",datas[@"fans"]];
//            self.totalpeos.text =  [NSString stringWithFormat:@"%@个",datas[@"man"]];
//            self.total_Live.text = [NSString stringWithFormat:@"共直播%@场",datas[@"chang"]];
//            self.total_Money.text =   [NSString stringWithFormat:@"%@元",datas[@"total_price"]];
//            self.totalSale.text=  [NSString stringWithFormat:@"%@件",datas[@"salegoods"]];
//            self.total_time.text = [NSString stringWithFormat:@"%@小时",datas[@"live_length"]];
        }
    } failure:^(NSError *error) {
        
    }];
}
-(void)setUpView{
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    [flowLayout setItemSize:CGSizeMake(self.CollectView.frame.size.width/2-10, 100)];
    [flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
    flowLayout.headerReferenceSize = CGSizeMake(self.CollectView.frame.size.width, 40);
    [self.CollectView setCollectionViewLayout:flowLayout];
    self.CollectView.delegate = self;
    self.CollectView.dataSource = self;
    UINib *cellNib = [UINib nibWithNibName:@"Album_Cell" bundle:nil];
    [self.CollectView registerNib:cellNib forCellWithReuseIdentifier:@"simpleCell"];
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.dataSouce.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"simpleCell";
    Album_Cell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
    //    if (self.contetnData.count>0) {
    //        [cell bindData:self.contetnData[indexPath.row]];
    //    }
    return cell;
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    return CGSizeMake(self.CollectView.frame.size.width/2-10, 190);
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
